package com.base.engine.gui;

import com.base.engine.game.MADGame;
import com.base.engine.graphics.Color4f;
import com.base.engine.graphics.EDisplayMode;
import com.base.engine.graphics.IMADDisplayable;
import com.base.engine.graphics.MADRenderer;
import com.base.engine.graphics.VertexArray2f;

import static org.lwjgl.opengl.GL11.*; 

public abstract class MADGamingInterface implements IMADDisplayable{

	public static final float[] u = {0,1,1,0} ; 
	public static final float[] v = {1,1,0,0} ;	
	
	protected VertexArray2f vertices ; 
	private float left, top ; 
	private float width, height;	
	private String name ; 
	private boolean visible = true ; 
	private MADGame game ; 
	
	public MADGamingInterface(MADGame g, float left, float top, float width, float height, String name){
		game = g ; 
		setLeft(left);
		setTop(top);
		setWidth(width);
		setHeight(height);
		setName(name);
		vertices = MADRenderer.toRectangle_2f(left, top, width, height, u, v, 
											  new Color4f(0.25f,0.25f,0.25f,0.95f),
											  EDisplayMode.DM_COLORED, name);
	}

	public float getLeft() {
		return left;
	}

	public void setLeft(float left) {
		this.left = left;
	}

	public float getTop() {
		return top;
	}

	public void setTop(float top) {
		this.top = top;
	}

	public float getWidth() {
		return width;
	}

	public void setWidth(float width) {
		this.width = width;
	}

	public float getHeight() {
		return height;
	}

	public void setHeight(float height) {
		this.height = height;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public boolean isVisible() {
		return visible;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	public MADGame getGame() {
		return game;
	}


	public void update(){}
	
	public void render(){
		if(isVisible()){
			glPushMatrix();
				MADRenderer.renderRectangle_2f(vertices, null, GL_QUADS);
			glPopMatrix();
		}
	}
	
}
